package com.geen.tuoke

import android.app.Activity
import android.app.Application
import android.content.Context
import androidx.multidex.MultiDex
import com.blankj.utilcode.util.LogUtils
import com.tencent.bugly.Bugly
import com.tencent.mmkv.MMKV
import me.jessyan.autosize.AutoSizeConfig
import me.jessyan.autosize.onAdaptListener
import me.jessyan.autosize.utils.ScreenUtils

/**
 * @Author LuoJi
 * @Date 2021/12/12-14:45
 * @Desc
 */
class MyApplication : Application() {

    override fun onCreate() {
        super.onCreate()
        instance = this
        MMKV.initialize(this)
        initAutoSize()
        Bugly.init(applicationContext, "3a8193aee0", true);

        LogUtils.getConfig().setGlobalTag("log_show")
    }

    override fun attachBaseContext(base: Context?) {
        super.attachBaseContext(base)
        MultiDex.install(this)
    }

    companion object {
        lateinit var instance: MyApplication
    }

    private fun initAutoSize() {
//        AutoSize.initCompatMultiProcess(this);
        AutoSizeConfig.getInstance().isUseDeviceSize = true
        //  AutoSize框架 兼容横竖屏幕 问题
        AutoSizeConfig.getInstance().onAdaptListener = object : onAdaptListener {
            override fun onAdaptBefore(target: Any, activity: Activity) {
                AutoSizeConfig.getInstance().screenWidth = ScreenUtils.getScreenSize(activity)[0]
                AutoSizeConfig.getInstance().screenHeight = ScreenUtils.getScreenSize(activity)[1]
            }

            override fun onAdaptAfter(target: Any, activity: Activity) {}
        }
    }




}